import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import AutoImport from 'unplugin-auto-import/vite'
import eslintPlugin from 'vite-plugin-eslint'
// https://vitejs.dev/config/
export default defineConfig({
  server: {
    proxy: {
      '/api': {
        target: 'https://sqapi2.dishawang.com/api/v1',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
  plugins: [
    uni(),
    eslintPlugin({
      include: [
        'src/**/*.js',
        'src/**/*.vue',
        'src/**/*.jsx',
        'src/**/*.ts',
        'src/**/*.d.ts'
      ],
      exclude: ['node_modules/**', 'src/wxcomponents/vant/**'], // 排除不需要检查的目录
      cache: false,
      fix: true
    }),
    import('unocss/vite').then((unocss) => unocss.default()),
    AutoImport({
      dts: 'src/typings/auto-imports.d.ts',
      imports: ['vue', 'uni-app', 'pinia'],
      dirs: ['src/store']
    })
  ]
})
